
<?php
	
	
			
	// Build SQL Query  
	
	$queryTypes = "SELECT tbartifacts_type.Id, tbartifacts_type.Name 	          
			  FROM   tbartifacts_type ";
			
	mysql_query("set names utf8");
	 
	$numresultsTypes = mysql_query($queryTypes);
	 
	if (!$numresultsTypes) 
	{
		die('Invalid query: ' . mysql_error());
	}
	 
	$numrowsTypes = mysql_num_rows($numresultsTypes);
	
	// Writing the table with the query results. 
	echo (" <select name='artifactstype' id='artifactstype'>");
	echo ("<option>Tipo de Artefato</option>");
		 
	while ($rowTypes = mysql_fetch_assoc($numresultsTypes)) 
	{ 	
		if( $rowTypes["Id"] == $row["TypeId"])
		{
			echo ("<option SELECTED value='" . $rowTypes["Id"] . "'>" . $rowTypes["Name"] . "</option>");
		}
		else
		{
			echo ("<option value='" . $rowTypes["Id"] . "'>" . $rowTypes["Name"] . "</option>");
		}
	}// while
	
	echo (" </select> ");
		
	
	// If we have no results, offer a google search as an alternative
	
	if ($numrowsTypes == 0)
	{
		echo (" <select name='Artifacts Type'>");
		echo ("<option>Tipo de Artefato</option>");
		echo ("<option>Nenhum tipo criado</option>");
		echo (" </select> ");
	}//if
	
	  
?>